<include file="../header" />
<body class="J_scroll_fixed">
    <script type="text/javascript" src="__ROOT__/statics/js/ajaxfileupload.js"></script>
    <script type="text/javascript" src="__ROOT__/statics/js/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" src="__ROOT__/statics/js/ueditor/ueditor.all.min.js"></script>

    <script type="text/javascript">
        $(function () {

            $("button#upload").click(function(){
                //上传文件
                $.ajaxFileUpload({
                    url:"{:U('Guide/uploadImage')}",//处理图片脚本
                    secureuri :false,
                    fileElementId :'fileToUpload',//file控件id
                    dataType : 'json',
                    success : function (data, status){
                        $("input[name=iconPath]").val(data);
                        $("img[name=preImage]").attr("src", data);
                    },
                    error: function(data, status, e){
                        alert(e);
                    }
                })
            });

        });
    </script>
    <div class="wrap jj">
        <ul class="nav nav-tabs">
            <li><a href="{:U('guide/index')}">导航列表</a></li>
            <li class="active"><a href="{:U('guide/add')}">添加导航</a></li>
        </ul>

        <div class="common-form">
            <form  id='add' method="post" class="form-horizontal J_ajaxForm" action="{:U('guide/addPost')}">
                <fieldset>
                    <div class="control-group">
                        <label class="control-label">名称：</label>
                        <div class="controls">
                            <input type="text" name="name" />
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">目标链接：</label>
                        <div class="controls">
                            <input type="text" name="targetUrl" />
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">图标预览</label>
                        <div class="controls">
                            <img src="" name="preImage" style="width:224px;height:168.5px;" />
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">上传图标</label>
                        <div class="controls">
                            <input id="fileToUpload" type="file" name="fileToUpload" style="width:170px;">
                            <button class="btn" type="button" id="upload">上传</button>
                            <input type="hidden" name="iconPath" value="" />
                        </div>
                    </div>
                </fieldset>

                <div class="form-actions">
                    <button id='send' type="submit" class="btn btn-primary">添加</button>
                    <a class="btn" href="__URL__">返回</a>
                </div>
            </form>
        </div>
    </div>
    <script src="__ROOT__/statics/js/common.js"></script>
</body>
</html>